package code.rocky.consumer;

import java.util.concurrent.TimeUnit;

public class InterruptTest {

    public static void main(String[] args) throws InterruptedException {
        Thread mainThread = Thread.currentThread();
        new Thread(() -> {
            System.out.println("====start======");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            mainThread.interrupt();
            System.out.println("====end========");
        }).start();

        // interrupt 字面意思是中断,实际上不能中断
        while (true) {
            // 这样子包一层能中断 加一层try catch 中断不了 手动休眠也中断不了
            Thread.sleep(1000);
            System.out.println(mainThread.getName() + " ======");
        }
    }
}
